import 'package:flutter/material.dart';

void main() => runApp(new MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    int _counter = 0;
    return new MaterialApp(
      title: 'welcome to Flutter',
      theme: new ThemeData(primarySwatch: Colors.blue),
      home: new MyHomePage(
        title: 'Flutter demo home page',
      ),
//      home: new Scaffold(
//        appBar: new AppBar(
//          title: new Text('welcom to Flutterwelcom to Fluttewelcom to Fluttewelcom to Fluttewelcom to Flutte'),
//          backgroundColor: Colors.lightBlueAccent,
//          centerTitle: true,
//          actions: <Widget>[
//            new IconButton(icon: Icon(Icons.add_a_photo), padding: EdgeInsets.only(right: 20, left: 30), onPressed: () {
//              print('拍照');
//            }),
//          ],
//        ),
//
//        body: new Center(
//
//        ),
//      ),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);
  final String title;

  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return new MyHomePageState();
  }
}

class MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  void _addCounter() {
    setState(() {
      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return new Scaffold(
      appBar: new AppBar(
        title: new Text('计时器'),
        backgroundColor: Colors.orange,
      ),
      body: new Center(
        child: new Container(
          margin: EdgeInsets.only(left: 10, right: 10, top: 10, bottom: 34),
          decoration: new BoxDecoration(color: Colors.greenAccent),
          child: new Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              new Text(
                'You have pushed the button this many times:',
                style: new TextStyle(fontSize: 20),
                textAlign: TextAlign.center,
                maxLines: 1,
                overflow: TextOverflow.ellipsis, //截断方式 ...
              ),
              new Text(
                '$_counter',
                style: new TextStyle(
                    fontSize: 40,
                    color: Colors.orange,
                    backgroundColor: Colors.lightGreenAccent),
              ),
            ],
          ),
        ),
      ),
      floatingActionButton: new FloatingActionButton(
          child: new Icon(Icons.add),
          backgroundColor: Colors.orange,
          foregroundColor: Colors.white,
          onPressed: _addCounter),
    );
  }
}
